from pydantic import BaseModel, Field
from typing import Any
from fastapi.responses import JSONResponse

class ResponseModel(BaseModel):
    status_code:int = Field(default=200, description='状态码')
    message:str = Field(default='success', description='状态信息')
    data:Any | None


class HttpResponse(object):

    @staticmethod
    def success(data:Any | None ):
        return JSONResponse(content=ResponseModel(status_code=200, message='success', data=data).model_dump())

    @staticmethod
    def failed(status_code: int,  data: Any = None):
        return JSONResponse(content=ResponseModel(status_code=status_code, message='failed', data=data).model_dump())